package com.xinqi.modules.prepare.question.manager;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.prepare.question.domain.PrepareQuestionFolderRefEntity;
import com.xinqi.modules.prepare.question.dto.QuestionSortDTO;
import com.xinqi.modules.prepare.question.dto.req.PrepareQuestionFolderRefQueryDTO;
import com.xinqi.modules.prepare.question.dto.rsp.PrepareQuestionBankResultDTO;
import com.xinqi.modules.prepare.question.dto.rsp.PrepareQuestionFolderRefResultDTO;
import com.xinqi.modules.prepare.question.dto.rsp.PrepareQuestionStatsDataDTO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 备课区试题夹关联题目管理层
 *
 * @author: system
 * @date: 2023/03/19
 */
public interface PrepareQuestionFolderRefManager extends BaseService<PrepareQuestionFolderRefEntity> {

    /**
     * 自定义分页查询
     */
    Page<PrepareQuestionFolderRefResultDTO> findPage(Page<Object> page, PrepareQuestionFolderRefQueryDTO query);

    IPage<PrepareQuestionBankResultDTO> questionPage(Page<Object> page, PrepareQuestionFolderRefQueryDTO dto);

    PrepareQuestionStatsDataDTO questionStats(Long prepareId, Long questionFolderId);

    /**
     * 自定义列表查询
     */
    List<PrepareQuestionFolderRefResultDTO> findList(PrepareQuestionFolderRefQueryDTO query);

    /**
     * 根据id查询 备课区试题夹关联题目数据
     */
    PrepareQuestionFolderRefEntity findById(Long id);

    /**
     * 根据id删除 备课区试题夹关联题目数据
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteById(Long id);

    @Transactional(rollbackFor = Exception.class)
    void deletedByFolderIds(List<Long> folderIds);

    @Transactional(rollbackFor = Exception.class)
    Boolean joinQuestionFolder(Long prepareId, Long questionFolderId, List<Long> questionIds);

    @Transactional(rollbackFor = Exception.class)
    Boolean removeQuestionFolder(Long prepareId, Long questionFolderId, List<Long> questionIds);

    @Transactional(rollbackFor = Exception.class)
    Boolean sortFolderQuestion(Long prepareId, Long questionFolderId, List<QuestionSortDTO> sorts);
}
